﻿function changeCss(obj) {
    var id = $(obj).val();
    for (var i = 1; i < 5; i++) {
        if (i == id)
            document.getElementById("CSS" + i).disabled = false;
        else
            document.getElementById("CSS" + i).disabled = true;
    }
}
//初始化左侧
function InitLeftMenu(obj) {
    $.each(obj.menus, function (i, n) {
        $('#leftmuen').accordion('add', {
            title: n.menuname,
            content: ChildMenu(n.menus)
        });
    });
    $('.easyui-accordion li a').click(function () {
        var tabTitle = $(this).text();
        var url = $(this).attr("href");
        addTab(tabTitle, url);
        $('.easyui-accordion li div').removeClass("selected");
        $(this).parent().addClass("selected");
    }).hover(function () {
        $(this).parent().addClass("hover");
    }, function () {
        $(this).parent().removeClass("hover");
    });

    $(".accordion").accordion({
        border: false,
        fit: true,
        collapsible: false,
        active: 0
    });
}
function ChildMenu(cmenu) {
    var str = "<ul>";
    $.each(cmenu, function (j, o) {
        str += "<li><div>";
        str += '<a target="mainFrame"  href="' + o.url + '" ><span class="icon ' + o.icon + '" ></span>' + o.menuname + '</a>';
        str += "</div></li>";
    });
    str += "</ul>";
    return str;
}
function addTab(subtitle, url) {
    if (!$('#tabs').tabs('exists', subtitle)) {
        $('#tabs').tabs('add', {
            title: subtitle,
            content: createFrame(url),
            closable: true,
            width: $('#mainPanle').width() - 10,
            height: $('#mainPanle').height() - 26,
            closable: true
        });
    } else {
        $('#tabs').tabs('select', subtitle);
    }
}
function createFrame(url) {
    var s = '<iframe name="mainFrame" scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
    return s;
}